package collection;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;

/** 集合的排序：整数 */
public class SortInteger {
    public static void main(String[] args) {
        Random random = new Random();
        List<Integer> list = new ArrayList<>();
        for (int i = 0;i<9;i++){
            list.add(random.nextInt(100));
        }
        System.out.println(list);
        Collections.sort(list);
        System.out.println(list);
        Collections.reverse(list);
        System.out.println(list);
        System.out.println(list.get(0));
       /* Random random = new Random();
        List<Integer> list = new ArrayList<>();
        for(int i = 0;i<10;i++){
            list.add(random.nextInt(100));
        }
        System.out.println("list原数组："+list);
        Collections.sort(list);
        System.out.println("list排序后:"+list);
        Collections.reverse(list);
        System.out.println("反转后的list："+list);
        System.out.println("list第一个元素："+list.get(0));*/
        /*Random rand = new Random();
        List<Integer> list = new ArrayList<>();
        for(int i = 0;i<10;i++){
            list.add(rand.nextInt(100));
        }
        System.out.println("list原始数据："+list);
        Collections.sort(list);
        System.out.println("排序后的list数据："+list);//原始排列 小到大
        Collections.reverse(list);
        System.out.println("反转后的list数据："+list);//大到小
        System.out.println("list的第一个元素："+list.get(0));*/
    }
}
